package com.wasion.pwportable.protocol.analyzer.indicator;

import com.wasion.pwportable.protocol.analyzer.AbstractAnalyzer;

/**
 * 
 * @ClassName: Line_Fault_RD_Analyzer
 * @Description: 77. 线路故障统计
 * @author 高意
 * @date 2014-9-11 上午9:51:16
 * 
 */
public class Line_Fault_RD_Analyzer extends AbstractAnalyzer {

	@Override
	public void dataAnalysis(String ackBS) {

		String dataLen = ackBS.substring(DATALENGTHSTARTBIT,
				DATALENGTHSTARTBIT + 2);

		if (dataLen.equalsIgnoreCase("15")) {
			String data = ackBS.substring(DATABITSTART, DATABITSTART + 24);

			result.setTempShortCount(Integer.parseInt(data.substring(0, 2), 16));
			result.setPermShortCount(Integer.parseInt(data.substring(2, 4), 16));

			result.setTempGroundCount(Integer.parseInt(data.substring(4, 6), 16));
			result.setPermGroundCount(Integer.parseInt(data.substring(6, 8), 16));

			result.setTempOverHeatCount(Integer.parseInt(data.substring(8, 10),
					16));
			result.setPermOverHeatCount(Integer.parseInt(
					data.substring(10, 12), 16));

			result.setQueryCount(Integer.parseInt(
					data.substring(14, 16) + data.substring(12, 14), 16));
			result.setFaultAckCount(Integer.parseInt(data.substring(18, 20)
					+ data.substring(16, 18), 16));
			result.setWarningResetCount(Integer.parseInt(data.substring(22, 24)
					+ data.substring(20, 22), 16));
		} else if (dataLen.equalsIgnoreCase("13")) // 架空型的数据
		{
			String data = ackBS.substring(DATABITSTART, DATABITSTART + 20);
			result.setTempShortCount(Integer.parseInt(data.substring(0, 2), 16));
			result.setPermShortCount(Integer.parseInt(data.substring(2, 4), 16));

			result.setTempGroundCount(Integer.parseInt(data.substring(4, 6), 16));
			result.setPermGroundCount(Integer.parseInt(data.substring(6, 8), 16));

			result.setQueryCount(Integer.parseInt(
					data.substring(10, 12) + data.substring(8, 10), 16));

			result.setFaultAckCount(Integer.parseInt(data.substring(14, 16)
					+ data.substring(12, 14), 16));

			result.setWarningResetCount(Integer.parseInt(data.substring(18, 20)
					+ data.substring(16, 18), 16));

			// 架空型的数据回应帧，忽略瞬时过温次数和 永久过温次数
		}
	}
}
